<template>
  <div id="homeAside">
    <el-menu
      default-active="1-4-1"
      class="el-menu-vertical-demo"
      :collapse="isCollapse"
    >
      <el-submenu
        v-for="(menu, i) in menus"
        :key="menu.id"
        :index="menu.path + i"
      >
        <template slot="title">
          <i :class="menu.icon"></i>
          <span slot="title">{{ menu.name }}</span>
        </template>
        <el-menu-item-group
          v-for="children in menu.children"
          :key="children.path"
          :index="children.path"
        >
          <router-link class="link_font-none" :to="{ path: children.path }">
            <el-menu-item>
              {{ children.name }}
            </el-menu-item>
          </router-link>
        </el-menu-item-group>
      </el-submenu>
      <!-- <el-submenu index="2">
        <template slot="title"><i class="el-icon-menu"></i>导航二</template>
        <el-menu-item-group>
          <router-link class="link_font-none" to="/driver">
            <el-menu-item>
              定时
            </el-menu-item>
          </router-link>
        </el-menu-item-group>
      </el-submenu> -->
    </el-menu>
  </div>
</template>

<script>
import { getmenuList } from "@/api/menu.js";
export default {
  name: "AsideView",

  data() {
    return {
      menus: this.$route.query.name,
      isCollapse: false,
    };
  },
  methods: {
    menuslonding() {
      getmenuList().then(({data}) => {
        console.log(data.page);
          if (data && data.code === 0) {
            this.menus = data.page
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
        .catch((err) => {
          this.$message.error("请求出错了：" + err);
        });

    },
  },
  mounted() {
    this.menuslonding();
  },
};
</script>

<style lang="scss" scoped>
#homeAside {
  padding: 0;
  margin: 0;
  background-color: #d3dce6;
  color: #333;
  text-align: center;
}
.link_font-none {
  text-decoration: none;
}
.link_font-none > .el-menu-item {
  color: #333;
}
</style>